import { createStore } from 'vuex'

declare let SessionStorage: any;
const USER="USER";
 const store=createStore({
  state: {//加载get对象获取不到就返回空对象
    user: SessionStorage.get(USER) ||{}
  },
  mutations: {
    //state是默认自带内部变量
    setUser(state,user){
      state.user=user;
      //放到缓存
      SessionStorage.set(USER,user);
    }
  },
  actions: {
  },
  modules: {
  }
})
export default store;